using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HeadspringExample.Core.Domain;
using HeadspringExample.Core.Domain.Model;
using HeadspringExample.UI.Models;

namespace HeadspringExample.UI.Helpers.Handlers
{
	public class AttendeeEditModelFormHandler : IFormHandler<AttendeeEditModel>
	{
		private readonly IConferenceRepository _repository;

		public AttendeeEditModelFormHandler(IConferenceRepository repository)
        {
            _repository = repository;
        }

		public void Handle(AttendeeEditModel form)
		{
			var entity = _repository.GetById(form.EventId);
			var attendee = new Attendee(form.FirstName, form.LastName)
			{
				Email = form.Email
			};
			attendee.RegisterFor(entity);
		}
	}
}